<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>登录页</title>
    <meta charset="utf-8">
    <base href="<%=basePath%>">
    <script type="text/javascript" src="<%=basePath%>APP/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/processbar/nprogress.js"></script>
	<link href="<%=basePath%>scripts/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
    <script src="<%=basePath%>scripts/boot.js" type="text/javascript"></script> 
    <style type="text/css"> 
	</style>
  </head>
  
  <body>
  	  <div style="width: 100%;height: 100%">
  		<img alt="" src="APP/AppImages/login.png" style="width: 100%;height:99%">
  		 <table style="width: 100%;height:40%;margin-top: -70%" >
  		<tr>
  			<td  align="center" height="30%" colspan="2" >
  				<img alt="" src="APP/AppImages/account.jpg" style="display: inline"> 
  				<input id="username" type="text" style="font-size: 16;display: inline"/>
  			</td>
  		</tr>
  		<tr>
  			<td  align="center" height="30%" colspan="2" >
  				<img alt="" src="APP/AppImages/password.jpg" style="display: inline"> 
  				<input id="userpwd" type="password" style="font-size: 16;display: inline"/>
  			</td>
  		</tr>
  		<tr >
  			<td colspan="2" height="40%" align="center">
  				<img alt="" width="53%"  src="APP/AppImages/login_button.png" onclick="login()"/>
  			</td>
  		</tr>
  	</table>
  	 </div>
  	 <script type="text/javascript">
  	 	function login(){
  	 		var $userName = $('#username'),
				$userPwd = $('#userpwd');
			if (isNull($userName.val())&&isNull($userPwd.val())){
				alert('账号和密码不得为空!');
				$userName.focus();
				return false;
			}
		   if (isNull($userName.val())){
				alert('账号不得为空!');
				$userName.focus();
				return false;
			}
			if (isNull($userPwd.val())){
				alert('密码不得为空!');
				$userName.focus();
				return false;
			}
			if (!(/^[_0-9a-zA-Z]*$/g.test($.trim($userName.val())))){
				alert('输入内容只能包含大小写字母、数字和下划线!');
				$userName.focus();
				return false;
			}
		    $.ajax({
				type : "post",
				url : "user/login.do",
				data : {
				loginname:$userName.val(),
				loginpassword:$userPwd.val(),
				ip:""
				},
				datatype : "json",
				success : function(text) {
				    var list = eval("(" + text + ")");
					if('fail' == list.success){
						alert('用户名或密码错误!');
					}else{
						window.location="APP/AppIndex.jsp";
					}
				}
			});
  	 	}
  	 	function isNull(v){
			return $.trim(v)=='';
		}
  	 </script>
  </body>
</html>
